<?php
//----------------------------------------------------------------------------------------------------------
if (!$_GET['pass'] || $_GET['pass']!="trytoguess") exit("You have no permission to view this page");

    require_once('../config.inc.php');

    require_once($config['app_dir'] . '/classes/stockmailer.data.php');
	require_once($config['app_dir'] . '/includes/db.class.php');




	class getMails extends objStockMailerModel {
		public $_db = false;

		public function __contruct(){
			$this->_db = objDataBase::GetInstance();

		}
	}

	$mails = new getMails();




	//echo "<b>MessageType = 1 :</b><br>";
	$data_sessions = $mails->_db->handler->getAll("SELECT * FROM fa_mailer_sessions ORDER BY SessionID desc");



   	foreach($data_sessions as $item) {   					$sessioid = $item['SessionID'];
   					$session = $mails->_db->handler->getRow("SELECT m.Body, f.TradeID, f.SystemID  FROM fa_mailer_mails m LEFT JOIN vfa_forecast f ON f.ForecastID = m.ForecastID WHERE SessionID=".$sessioid." AND MessageType=4");
   					$subject = $mails->_db->handler->getRow("SELECT Body FROM fa_mailer_mails   WHERE SessionID=".$sessioid." AND MessageType=3");
   					$subject_raw = explode("@",$subject['Body']);
   					$subject_net = $subject_raw[0];


   					//$fcastid = $session['ForecastID'];
   					$tradeid = $session['TradeID'];
   					$systemid = $session['SystemID'];





   		          echo "<b><a href='test_users.php?pass=trytoguess&trade=".$tradeid."&session=".$sessioid."&system=".$systemid."'>Session ";
                  echo $sessioid." - ".$item['Date']." GMT";
                  echo "</a></b>  - Click to view emails";
				  echo "<br>";
				  echo "<b>Subject:</b> ".$subject_net;
				  echo "<br><b>HTML Body:</b><br>";
				  echo "<textarea rows='5' cols='100'>".$session['Body']." <br><br></textarea><br>";
				  echo "<b>Preview:</b><br>";
				  echo "".$session['Body'];
				  echo "<br><br><br><hr><hr>";
    }

   	echo "<br><br><br>";



?>
